from rest_framework import serializers
from goods.models import SPUSpecification, SPU


# 商品规格表的序列化
class SPUSpecificationSerialzier(serializers.ModelSerializer):

    spu_id = serializers.IntegerField()

    spu = serializers.StringRelatedField(read_only=True)


    class Meta:
        model = SPUSpecification
        fields = ('id','name','spu','spu_id')

class SPUSerializer(serializers.ModelSerializer):
    class Meta:
        # 指定根据那个模型类生成序列化器字段
        model = SPU
        # 指定那些字段生成
        fields = ('id','name')